package day6.Vehicle;

import java.util.Scanner;

//交通工具
public class Vehicle {
	/*
	 *   属性：速度(speed)，体积(size)等等
		  方法：移动(move())，加速speedUp(),减速speedDown()等等.
	 */
	
	
	
	private double speed;
	private double size;

	//移动
	public void move() {
		System.out.println("现在速度为 ：" + speed + "km/h，体积为：" +size +"kg,即移动距离为："+(speed * size)+"km");
		if (speed==0) {
			System.out.println("当前速度为0，需加速！");
		}
	}
	
	public double speedUp(double speed) {
		this.speed += speed;
		System.out.println("现在速度为"+this.speed+"km/h");
		return speed;
		
	}
	
	public int name(int x) {
		int y = 1;
		if (x == 1) {
			return x;
		}else {
			return y;
		}		
	}

	public double speedDown(double speed) {
		this.speed -= speed;
		if (this.speed >= 0) {
			System.out.println("现在速度为"+this.speed+"km/h");		
		}else {	
			System.out.println("当前速度为0，已停止");
			this.speed = 0;
		}
		return speed;
		
	}
	
	public Vehicle(double speed, double size) {
		this.speed = speed;
		this.size = size;
	}

	public double getSpeed() {
		return speed;
	}

	public void setSpeed(double speed) {
		this.speed = speed;
	}

	public double getSize() {
		return size;
	}

	public void setSize(double size) {
		this.size = size;
	}
	
	
	
}
